package com.lagou.vo;

import java.io.Serializable;

/**
 * @ClassName: Result
 * @Auther: Jerry
 * @Date: 2020/10/23 11:06
 * @Desctiption: TODO
 * @Version: 1.0
 */
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -7548312824808298611L;

    private Integer code; // 状态码
    private T data; // 内容
    private String msg; // 错误信息

    public static <T>  Result<T> error(String msg) {
        Result result = new Result();
        result.setCode(400);
        result.setMsg(msg);
        return result;
    }

    public static <T> Result<T> success(T data) {
        Result result = new Result();
        result.setCode(200);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> success(T data, String msg) {
        Result result = new Result();
        result.setCode(200);
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
